<template>
  <nav class="navbar">
    <div class="nav-container">
      <div class="nav-logo">
        <router-link to="/">张艺创作品集</router-link>
      </div>
      
      <div class="nav-menu" :class="{ 'nav-menu-active': isMenuOpen }">
        <router-link 
          v-for="item in navItems" 
          :key="item.name" 
          :to="item.path" 
          class="nav-link"
          @click="closeMenu"
          v-text="item.name"
        >
        </router-link>
      </div>
      
      <div class="nav-toggle" @click="toggleMenu">
        <span></span>
        <span></span>
        <span></span>
      </div>
    </div>
  </nav>
</template>

<script setup>
import { ref } from 'vue'

const isMenuOpen = ref(false)

const navItems = [
  { name: '首页', path: '/' },
  { name: '作品', path: '/gallery' },
  { name: '简历', path: '/resume' },
  { name: '联系', path: '/contact' }
]

const toggleMenu = () => {
  isMenuOpen.value = !isMenuOpen.value
}

const closeMenu = () => {
  isMenuOpen.value = false
}
</script>

<style scoped>
.navbar {
  background-color: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  position: fixed;
  top: 0;
  width: 100%;
  z-index: 1000;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 70px;
}

.nav-logo a {
  font-size: 1.8rem;
  font-weight: 700;
  color: #333;
  text-decoration: none;
  transition: color 0.3s ease;
}

.nav-logo a:hover {
  color: #42b983;
}

.nav-menu {
  display: flex;
  gap: 30px;
}

@media (max-width: 768px) {
  .nav-menu {
    position: fixed;
    left: -100%;
    top: 70px;
    flex-direction: column;
    background-color: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    width: 100%;
    text-align: center;
    transition: 0.3s;
    box-shadow: 0 10px 27px rgba(0, 0, 0, 0.05);
    padding: 20px 0;
  }

  .nav-menu-active {
    left: 0;
  }
}

.nav-link {
  font-size: 1.1rem;
  font-weight: 500;
  color: #333;
  text-decoration: none;
  transition: color 0.3s ease;
  position: relative;
}

.nav-link:hover {
  color: #42b983;
}

.nav-link.router-link-exact-active {
  color: #42b983;
}

.nav-link.router-link-exact-active::after {
  content: '';
  position: absolute;
  bottom: -5px;
  left: 0;
  width: 100%;
  height: 3px;
  background-color: #42b983;
  border-radius: 3px;
}

.nav-toggle {
  display: none;
  flex-direction: column;
  cursor: pointer;
}

@media (max-width: 768px) {
  .nav-toggle {
    display: flex;
  }
}

.nav-toggle span {
  width: 25px;
  height: 3px;
  background-color: #333;
  margin: 3px 0;
  transition: 0.3s;
  border-radius: 2px;
}

.nav-toggle span:nth-child(2) {
  width: 20px;
}

.nav-menu-active ~ .nav-toggle span:nth-child(1) {
  transform: rotate(-45deg) translate(-5px, 6px);
}

.nav-menu-active ~ .nav-toggle span:nth-child(2) {
  opacity: 0;
}

.nav-menu-active ~ .nav-toggle span:nth-child(3) {
  transform: rotate(45deg) translate(-5px, -6px);
}
</style>